using HKB.Alipay;
using HKB.Common;
using HKB.Data.Bll;
using HKB.Data.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
namespace HKB.Web
{
	public class OrderAction : HoWave_Root
	{
		private new Conn conn = null;
		public string payFrom = "buy";
		private GroupBll _bllGroup = null;
		private AccountDetailsBll _accountDetials = null;
		private DataRow _shopconfig = null;
		public GroupBll BllGroup
		{
			get
			{
				if (this._bllGroup == null)
				{
					this._bllGroup = new GroupBll(this.conn);
				}
				return this._bllGroup;
			}
		}
		public AccountDetailsBll accountDetials
		{
			get
			{
				if (this._bllGroup == null)
				{
					this._accountDetials = new AccountDetailsBll(this.conn);
				}
				return this._accountDetials;
			}
		}
		public DataRow shopconfig
		{
			get
			{
				if (this._shopconfig == null)
				{
					object obj = DataCache.GetCache("shopconfig");
					if (obj == null)
					{
						obj = new ShopConfigBll().GetConfig().Rows[0];
						if (obj != null)
						{
							int configInt = ConfigHelper.GetConfigInt("config");
							DataCache.SetCache("shopconfig", obj, DateTime.Now.AddMinutes((double)configInt), TimeSpan.Zero);
						}
					}
					this._shopconfig = (DataRow)obj;
				}
				return this._shopconfig;
			}
		}
		public OrderAction()
		{
		}
		public OrderAction(Conn _conn)
		{
			this.conn = _conn;
		}
		public bool ShopBankPayOrder(int UserID, int OrderID, decimal Money, string Remark, decimal fee, bool isShopMonery, string type, decimal mustfee)
		{
			DataTable dataTable = this.conn.GetDataTable("Select UserName,Balance From [HL_User] Where UserID=" + UserID);
			decimal d = Convert.ToDecimal(dataTable.Rows[0]["Balance"]);
			string text = dataTable.Rows[0]["UserName"].ToString();
			dataTable.Dispose();
			DataTable dataTable2 = this.conn.GetDataTable("Select OrderFormID,OrderFormNum,SalerID,Status,PayStatus,DeliverStatus From [HLShop_Order] Where OrderFormID=" + OrderID);
			string text2 = dataTable2.Rows[0]["OrderFormNum"].ToString();
			int num = Convert.ToInt32(dataTable2.Rows[0]["OrderFormID"]);
			int num2 = Convert.ToInt32(dataTable2.Rows[0]["Status"]);
			int num3 = Convert.ToInt32(dataTable2.Rows[0]["PayStatus"]);
			int num4 = Convert.ToInt32(dataTable2.Rows[0]["DeliverStatus"]);
			if (num2 == 0)
			{
			}
			if (num3 == 0)
			{
				num3 = 1;
			}
			int num5 = Convert.ToInt32(dataTable2.Rows[0]["SalerID"]);
			dataTable2.Dispose();
			bool result;
			if (d < Money + fee)
			{
				result = false;
			}
			else
			{
				string userBalanceKey = Text.GetUserBalanceKey(UserID, d - Money);
				IDbDataParameter dbDataParameter = this.conn.CreateParameter("@Remark", DbType.String, Remark);
				this.conn.BeginTransaction();
				try
				{
					if (isShopMonery)
					{
						decimal num6 = fee;
						if (type.Equals("1"))
						{
							num6 = 0m;
						}
						else
						{
							if (type.Equals("0"))
							{
							}
						}
						decimal balance = d - Money;
						decimal num7 = Money + num6;
						decimal num8 = d - num7;
						this.accountDetials.AddAccountDetailsByTransaction(UserID, Money, balance, 0, Remark);
						int num9 = (int)this.conn.ExecuteTransactionScalar("Select top 1 ID From HL_AccountDetails Where UserID=" + UserID + " Order By ID Desc");
						if (num6 != 0m)
						{
							this.conn.ExecuteTransaction(string.Concat(new object[]
							{
								"INSERT INTO HLShop_Records (UserId,OrderFormNum,Monery) VALUES(",
								UserID,
								",'",
								text2,
								"',",
								num6,
								")"
							}));
							this.accountDetials.AddAccountDetailsByTransaction(UserID, num6, num8, 0, "支付手续费");
						}
						this.conn.ExecuteTransaction(string.Concat(new object[]
						{
							"Insert Into HLShop_PayInfo(PaymentNum,PayTypeID,OrderFormNum,eBankID,MoneyPay,MoneyTrue,PayTime,Status,SalerID,UserID,UserName,Remark,MoneyFee) Values('",
							num9,
							"',0,'",
							text2,
							"','ShopBank',",
							Money,
							",",
							Money,
							",getdate(),'NotPaySaler',",
							num5,
							",",
							UserID,
							",'",
							text,
							"',@Remark,",
							num6,
							")"
						}), new IDbDataParameter[]
						{
							dbDataParameter
						});
						this.conn.ExecuteTransaction(string.Concat(new object[]
						{
							"Update [HLShop_Order] Set PayStatus=",
							num3,
							",MoneyReceipt=MoneyReceipt+",
							num7,
							" Where OrderFormID=",
							num
						}));
						string commandText = string.Concat(new object[]
						{
							"Update [HL_User] Set Balance=",
							num8,
							",FreezeMoney=FreezeMoney+",
							num7,
							",EncryptMoney='",
							userBalanceKey,
							"' Where UserID=",
							UserID
						});
						this.conn.ExecuteTransaction(commandText);
					}
				}
				catch
				{
					this.conn.Rollback();
					result = false;
					return result;
				}
				this.conn.Commit();
				result = true;
			}
			return result;
		}
		public bool CardPayOrder(int UserID, int OrderID, decimal Money, string Remark, string[] CardNumbers, string CardType)
		{
			bool result;
			if ((CardType == "-1" || CardType == "-2") && CardNumbers.Length <= 0)
			{
				result = false;
			}
			else
			{
				DataTable dataTable = this.conn.GetDataTable("Select OrderFormID,OrderFormNum,SalerID,Status,PayStatus,DeliverStatus From [HLShop_Order] Where OrderFormID=" + OrderID);
				string text = dataTable.Rows[0]["OrderFormNum"].ToString();
				int num = Convert.ToInt32(dataTable.Rows[0]["OrderFormID"]);
				int num2 = Convert.ToInt32(dataTable.Rows[0]["Status"]);
				int num3 = Convert.ToInt32(dataTable.Rows[0]["PayStatus"]);
				int num4 = Convert.ToInt32(dataTable.Rows[0]["DeliverStatus"]);
				if (num2 == 0)
				{
					num2 = 1;
				}
				if (num3 == 0)
				{
					num3 = 1;
				}
				int num5 = Convert.ToInt32(dataTable.Rows[0]["SalerID"]);
				dataTable.Dispose();
				decimal d = (decimal)this.conn.GetScalar("Select Balance From [HL_User] Where UserID=" + num5, new IDbDataParameter[0]);
				string userBalanceKey = Text.GetUserBalanceKey(num5, d + Money);
				IDbDataParameter dbDataParameter = this.conn.CreateParameter("@Remark", DbType.String, Remark);
				this.conn.BeginTransaction();
				decimal num6 = Money;
				try
				{
					UserCardRecordModel userCardRecordModel = new UserCardRecordModel(-1L, UserID, "", "", 0m, DateTime.Now, "");
					userCardRecordModel.UserTime = new DateTime?(DateTime.Now);
					string text2 = "";
					string text3 = "";
					userCardRecordModel.CardType = CardType;
					if (CardType == "-1")
					{
						userCardRecordModel.Remark = "vip卡支付商品";
						text3 = "vip";
						for (int i = 0; i < CardNumbers.Length; i++)
						{
							string text4 = CardNumbers[i];
							if (num6 > 0m)
							{
								decimal num7 = this.conn.ExecuteTransactionScalar("select Balance from MBF_UserVipCard where CardNumber = '" + text4 + "'").ToDecimal2();
								if (num7 > 0m)
								{
									decimal num8;
									if (num7 >= num6)
									{
										num8 = num6;
									}
									else
									{
										num8 = num7;
									}
									this.conn.ExecuteTransaction(string.Format("update MBF_UserVipCard set Balance=Balance-{0} where CardNumber='{1}'", num8, text4));
									userCardRecordModel.CardNumber = text4;
									userCardRecordModel.Amount = new decimal?(num8);
									text2 = text2 + Blls.bllUserCardRecord.Add(userCardRecordModel, new Conn[]
									{
										this.conn
									}) + ",";
									num6 -= num8;
								}
							}
						}
					}
					else
					{
						if (CardType == "-2")
						{
							userCardRecordModel.Remark = "礼品卡支付商品";
							text3 = "gift";
							for (int i = 0; i < CardNumbers.Length; i++)
							{
								string text4 = CardNumbers[i];
								if (num6 > 0m)
								{
									decimal num7 = this.conn.ExecuteTransactionScalar("select Balance from MBF_UserGiftCard where CardNumber = '" + text4 + "'").ToDecimal2();
									if (num7 > 0m)
									{
										decimal num8;
										if (num7 >= num6)
										{
											num8 = num6;
										}
										else
										{
											num8 = num7;
										}
										this.conn.ExecuteTransaction(string.Format("update MBF_UserGiftCard set Balance=Balance-{0} where CardNumber='{1}'", num8, text4));
										userCardRecordModel.CardNumber = text4;
										userCardRecordModel.Amount = new decimal?(num8);
										text2 = text2 + Blls.bllUserCardRecord.Add(userCardRecordModel, new Conn[]
										{
											this.conn
										}) + ",";
										num6 -= num8;
									}
								}
							}
						}
						else
						{
							if (CardType == "-3")
							{
								userCardRecordModel.Remark = "中奖券支付商品";
								text3 = "lottery";
								DataTable dataTable2 = Blls.bllUserLotteryCard.GetListRowid(2147483647, "UserID=" + UserID + " and datediff(dd,EffectiveTime,GetDate())<=0 and IsDeleted=0", "EffectiveTime asc", new string[]
								{
									"CardNumber"
								}).Tables[0];
								if (dataTable2 == null || dataTable2.Rows.Count == 0)
								{
									result = false;
									return result;
								}
								string[] array = new string[dataTable2.Rows.Count];
								for (int j = 0; j < dataTable2.Rows.Count; j++)
								{
									array[j] = dataTable2.Rows[j]["CardNumber"].ToString();
								}
								string[] array2 = array;
								for (int i = 0; i < array2.Length; i++)
								{
									string text4 = array2[i];
									if (num6 > 0m)
									{
										decimal num7 = this.conn.ExecuteTransactionScalar("select Balance from MBF_UserLotteryCard where CardNumber = '" + text4 + "'").ToDecimal2();
										if (num7 > 0m)
										{
											decimal num8;
											if (num7 >= num6)
											{
												num8 = num6;
											}
											else
											{
												num8 = num7;
											}
											this.conn.ExecuteTransaction(string.Format("update MBF_UserLotteryCard set Balance=Balance-{0} where CardNumber='{1}'", num8, text4));
											userCardRecordModel.CardNumber = text4;
											userCardRecordModel.Amount = new decimal?(num8);
											text2 = text2 + Blls.bllUserCardRecord.Add(userCardRecordModel, new Conn[]
											{
												this.conn
											}) + ",";
											num6 -= num8;
										}
									}
								}
							}
						}
					}
					if (num6 > 0m)
					{
						throw new Exception("卡余额不足，操作取消！");
					}
					if (text2.Length > 0)
					{
						text2 = text2.TrimEnd(new char[]
						{
							','
						});
					}
					if (num4 == 2)
					{
						this.conn.ExecuteTransaction(string.Concat(new object[]
						{
							"Update [HL_User] Set Balance=Balance+",
							Money,
							",EncryptMoney='",
							userBalanceKey,
							"' Where UserID=",
							num5
						}));
						this.conn.ExecuteTransaction(string.Concat(new object[]
						{
							"Insert Into HL_AccountDetails(UserID,cMoney,cType,uBalance,CreateTime,Remark) values(",
							num5,
							",",
							Money,
							",1,",
							d + Money,
							",getdate(),@Remark)"
						}), new IDbDataParameter[]
						{
							dbDataParameter
						});
						this.conn.ExecuteTransaction(string.Concat(new object[]
						{
							"Insert Into HLShop_PayInfo(PaymentNum,PayTypeID,OrderFormNum,eBankID,MoneyPay,MoneyTrue,PayTime,Status,SalerID,UserID,UserName,Remark) Values('",
							text2,
							"',0,'",
							text,
							"','",
							text3,
							"',",
							Money,
							",",
							Money,
							",getdate(),'pay',",
							num5,
							",",
							UserID,
							",'",
							StaticFun.GetUserNameByid(new int?(UserID)),
							"',@Remark)"
						}), new IDbDataParameter[]
						{
							dbDataParameter
						});
						this.conn.ExecuteTransaction(string.Concat(new object[]
						{
							"Update [HLShop_Order] Set PayStatus=",
							num3,
							",MoneyReceipt=MoneyReceipt+",
							Money,
							" Where OrderFormID=",
							num
						}));
					}
					else
					{
						if (text3 == "")
						{
							text3 = "shopbank";
						}
						this.conn.ExecuteTransaction(string.Concat(new object[]
						{
							"Insert Into HLShop_PayInfo(PaymentNum,PayTypeID,OrderFormNum,eBankID,MoneyPay,MoneyTrue,PayTime,Status,SalerID,UserID,UserName,Remark) Values('",
							text2,
							"',",
							CardType,
							",'",
							text,
							"','",
							text3,
							"',",
							Money,
							",",
							Money,
							",getdate(),'NotPaySaler',",
							num5,
							",",
							UserID,
							",'",
							StaticFun.GetUserNameByid(new int?(UserID)),
							"',@Remark)"
						}), new IDbDataParameter[]
						{
							dbDataParameter
						});
						this.conn.ExecuteTransaction(string.Concat(new object[]
						{
							"Update [HLShop_Order] Set Status=",
							num2,
							",PayStatus=",
							num3,
							",MoneyReceipt=MoneyReceipt+",
							Money,
							" Where OrderFormID=",
							num
						}));
					}
				}
				catch (Exception ex)
				{
					this.conn.Rollback();
					ex.WriteErrorLog(new string[0]);
					result = false;
					return result;
				}
				this.conn.Commit();
				result = true;
			}
			return result;
		}
		public bool OffLinePayOrder(int OrderFormID, int UserID, decimal Money, DateTime paytime, int PayTypeID, string Remark)
		{
			DataTable dataTable = this.conn.GetDataTable("Select UserID,BuyerName,SalerID,OrderFormNum,PayStatus,Status From [HLShop_Order] Where OrderFormID=" + OrderFormID);
			bool result;
			if (dataTable.Rows.Count <= 0)
			{
				result = false;
			}
			else
			{
				int num = Convert.ToInt32(dataTable.Rows[0]["Status"]);
				int num2 = Convert.ToInt32(dataTable.Rows[0]["PayStatus"]);
				if (num2 == 0)
				{
					num2 = 1;
				}
				if (num == 0)
				{
					num = 1;
				}
				dataTable.Dispose();
				string value = "";
				string value2 = "";
				DataTable dataTable2 = this.conn.GetDataTable("Select TypeName,Intro From HLShop_PayType Where TypeID=" + PayTypeID);
				if (dataTable2.Rows.Count > 0)
				{
					value = dataTable2.Rows[0]["TypeName"].ToString();
					value2 = dataTable2.Rows[0]["Intro"].ToString();
				}
				IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@Remark", DbType.String, Remark),
					this.conn.CreateParameter("@eBankID", DbType.String, value),
					this.conn.CreateParameter("@eBankInfo", DbType.String, value2)
				};
				this.conn.BeginTransaction();
				try
				{
					this.conn.ExecuteTransaction(string.Concat(new object[]
					{
						"Update [HLShop_Order] Set Status=",
						num,
						",PayStatus=",
						num2,
						" Where OrderFormID=",
						OrderFormID
					}));
					this.conn.ExecuteTransaction(string.Concat(new object[]
					{
						"Insert Into [HLShop_PayInfo](UserName,UserID,PayTypeID,OrderFormNum,PaymentNum,eBankID,eBankInfo,MoneyPay,MoneyTrue,PayTime,Status,SalerID,Remark) values('",
						dataTable.Rows[0]["BuyerName"],
						"',",
						UserID,
						",0,'",
						dataTable.Rows[0]["OrderFormNum"],
						"','0',@eBankID,@eBankInfo,",
						Money,
						",",
						Money,
						", getdate(),'NotPay',",
						dataTable.Rows[0]["SalerID"],
						", @Remark)"
					}), parameters);
				}
				catch
				{
					this.conn.Rollback();
					result = false;
					return result;
				}
				this.conn.Commit();
				result = true;
			}
			return result;
		}
		public bool OffLinePayOrder(int OrderFormID, int PayTypeID, string Remark)
		{
			DataTable dataTable = this.conn.GetDataTable("Select UserID,BuyerName,SalerID,OrderFormNum,PayStatus,Status,MoneyTotal From [HLShop_Order] Where OrderFormID=" + OrderFormID);
			bool result;
			if (dataTable.Rows.Count <= 0)
			{
				result = false;
			}
			else
			{
				decimal num = Convert.ToDecimal(dataTable.Rows[0]["MoneyTotal"].ToString());
				string text = dataTable.Rows[0]["BuyerName"].ToString();
				int num2 = Convert.ToInt32(dataTable.Rows[0]["UserID"].ToString());
				string text2 = dataTable.Rows[0]["OrderFormNum"].ToString();
				int num3 = Convert.ToInt32(dataTable.Rows[0]["SalerID"].ToString());
				string value = "";
				string value2 = "";
				DataTable dataTable2 = this.conn.GetDataTable("Select TypeName,Intro From HLShop_PayType Where TypeID=" + PayTypeID);
				if (dataTable2.Rows.Count > 0)
				{
					value = dataTable2.Rows[0]["TypeName"].ToString();
					value2 = dataTable2.Rows[0]["Intro"].ToString();
				}
				IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@Remark", DbType.String, Remark),
					this.conn.CreateParameter("@eBankID", DbType.String, value),
					this.conn.CreateParameter("@eBankInfo", DbType.String, value2)
				};
				try
				{
					string sql = string.Concat(new object[]
					{
						"Update [HLShop_Order] Set MoneyReceipt=",
						num,
						" Where OrderFormID=",
						OrderFormID
					});
					this.conn.Execute(sql);
					string commandText = string.Concat(new object[]
					{
						"Insert Into [HLShop_PayInfo](UserName,UserID,PayTypeID,OrderFormNum,PaymentNum,eBankID,eBankInfo,MoneyPay,MoneyTrue,PayTime,Status,SalerID,Remark) values('",
						text,
						"',",
						num2,
						",",
						PayTypeID,
						",'",
						text2,
						"','0',@eBankID,@eBankInfo,",
						num,
						",",
						num,
						", getdate(),'pay',",
						num3,
						", @Remark)"
					});
					this.conn.Execute(commandText, parameters);
				}
				catch (Exception ex)
				{
					result = false;
					return result;
				}
				result = true;
			}
			return result;
		}
		public bool SendGoods(string OrderFormNum, string DeliverName, string DeliverCompany, string ExpressNumber, string Remark)
		{
			Shop_Order shop_Order = new Shop_Order(this.conn);
			DataTable orderByOrderFormNum = shop_Order.GetOrderByOrderFormNum(OrderFormNum);
			bool result;
			if (Convert.ToInt32(orderByOrderFormNum.Rows[0]["DeliverStatus"]) != 0)
			{
				result = false;
			}
			else
			{
				Shop_DeliverItem shop_DeliverItem = new Shop_DeliverItem(this.conn);
				result = (shop_DeliverItem.AddDeliverItem(Convert.ToInt32(orderByOrderFormNum.Rows[0]["UserID"]), Convert.ToInt32(orderByOrderFormNum.Rows[0]["SalerID"]), Convert.ToInt32(orderByOrderFormNum.Rows[0]["OrderFormID"]), 0, DeliverName, DateTime.Now, ExpressNumber, DeliverCompany, orderByOrderFormNum.Rows[0]["SalerName"].ToString(), Remark) && shop_Order.updateStatus(OrderFormNum, "", "1", ""));
			}
			return result;
		}
		public bool ShopBankReturnOrder(int OrderFormID)
		{
			bool flag = false;
			bool result;
			if (OrderFormID > 0)
			{
				string sql = "Select DeliverStatus,OrderFormNum,SalerID,UserID,SelectedPayType,PresentExpTotal,Deliver_TotalPrice,Invoice_TotalPrice,MoneyGoods,MoneyTotal From [HLShop_Order] Where OrderFormID=" + OrderFormID;
				DataTable dataTable = this.conn.GetDataTable(sql);
				if (dataTable.Rows.Count <= 0)
				{
					result = false;
					return result;
				}
				string text = dataTable.Rows[0]["OrderFormNum"].ToString();
				int num = Convert.ToInt32(dataTable.Rows[0]["SalerID"]);
				int num2 = Convert.ToInt32(dataTable.Rows[0]["UserID"]);
				decimal value = 0m;
				if (dataTable.Rows[0]["MoneyGoods"] != DBNull.Value)
				{
					value = dataTable.Rows[0]["MoneyGoods"].ToDecimal2();
				}
				decimal d = 0m;
				if (dataTable.Rows[0]["Deliver_TotalPrice"] != DBNull.Value)
				{
					d = dataTable.Rows[0]["Deliver_TotalPrice"].ToDecimal2();
				}
				if (dataTable.Rows[0]["Invoice_TotalPrice"] != DBNull.Value)
				{
					decimal num3 = dataTable.Rows[0]["Invoice_TotalPrice"].ToDecimal2();
				}
				int num4 = -100;
				if (dataTable.Columns.Contains("SelectedPayType"))
				{
					if (dataTable.Rows[0]["SelectedPayType"] != DBNull.Value)
					{
						num4 = Convert.ToInt32(dataTable.Rows[0]["SelectedPayType"].ToString());
					}
				}
				if (num4 == 0)
				{
					decimal num5 = 0m;
					decimal num6 = 0m;
					int num7 = 0;
					string value2 = "";
					string sqlpwhere = "Where eBankID='ShopBank' and LOWER(Status)='notpaysaler' and OrderFormNum='" + text + "' ";
					this.GetPayInfoMoneyAndIDBySqlWhere(ref num5, ref num6, ref num7, ref value2, sqlpwhere);
					decimal d2 = 0m;
					decimal d3 = 0m;
					this.GetUser_BalanceFreezeMoney(num2, ref d2, ref d3);
					if (d3 < num5 + num6)
					{
						this.WriteErrMsg("", Language.GetMemberMsg("Order/PayOrder/NotBalance", new string[0]), "");
						result = false;
						return result;
					}
					this.conn.BeginTransaction();
					try
					{
						if (num5 > 0m)
						{
							decimal d4 = num5 + num6;
							decimal num8 = d3 - d4;
							decimal num9 = d2 + num6;
							decimal num10 = num5 - d;
							decimal num11 = num9 + num10;
							if (num6 > 0m)
							{
								decimal num12 = 0m - num6;
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"INSERT INTO HLShop_Records (UserId,OrderFormNum,Monery) VALUES(",
									num2,
									",'",
									text,
									"',",
									num12,
									")"
								}));
								this.accountDetials.AddAccountDetailsByTransaction(num2, num6, num9, -1, "卖家/平台退款,手续费");
							}
							this.accountDetials.AddAccountDetailsByTransaction(num2, num10, num11, -1, "卖家/平台退款");
							string commandText = string.Concat(new object[]
							{
								"update HL_User set FreezeMoney=",
								num8,
								",Balance=",
								num11,
								" where UserID=",
								num2
							});
							this.conn.ExecuteTransaction(commandText);
							string commandText2 = "update HLShop_Order set PayStatus=2,Status=4,DeliverStatus=-2,MoneyReceipt=0 where OrderFormNum='" + text + "'";
							this.conn.ExecuteTransaction(commandText2);
							string commandText3 = "Update HLShop_DeliverItem Set Received=1 Where DeliverType=1 and OrderID=" + OrderFormID;
							this.conn.ExecuteTransaction(commandText3);
							DataTable dataTable2 = BLLInstance.BllStockInfoOrder.GetList("OrderID=" + OrderFormID).Tables[0];
							for (int i = 0; i < dataTable2.Rows.Count; i++)
							{
								int infoOrderID = dataTable2.Rows[i]["InfoOrderID"].ToInt32(new int[0]);
								string text2 = dataTable2.Rows[i]["InfoNumber"].ToString();
								HKB.Data.Model.StockInfoOrder model = BLLInstance.BllStockInfoOrder.GetModel(infoOrderID);
								if (model != null)
								{
									model.InfoOrderID = infoOrderID;
									model.Fee = new decimal?(0m);
									if (!string.IsNullOrEmpty(value2))
									{
										model.ReceiptDate = new DateTime?(Convert.ToDateTime(value2));
									}
									model.ReceiptMoney = new decimal?(num5);
									model.AlreadyReceiptMoney = new decimal?(0m);
									BLLInstance.BllStockInfoOrder.UpdateTransaction(model, this.conn);
								}
							}
							string commandText4 = "select UserName from HL_User where UserID=" + num;
							string inputer = "";
							object obj = this.conn.ExecuteTransactionScalar(commandText4);
							if (obj != null)
							{
								inputer = obj.ToString();
							}
							HKB.Data.Model.StockInfoOrder stockInfoOrder = new HKB.Data.Model.StockInfoOrder();
							string infoNumber = "RK" + DateTime.Now.TimeString();
							stockInfoOrder.InfoNumber = infoNumber;
							stockInfoOrder.CreateDate = new DateTime?(DateTime.Now);
							stockInfoOrder.Remark = "买家退货商品";
							stockInfoOrder.StockOrderType = "inPurchase";
							stockInfoOrder.StockStatus = new int?(1);
							stockInfoOrder.StockDate = new DateTime?(DateTime.Now);
							stockInfoOrder.Inputer = inputer;
							stockInfoOrder.OwnerID = num;
							stockInfoOrder.TotalMoney = new decimal?(value);
							int num13 = BLLInstance.BllStockInfoOrder.AddTransaction(stockInfoOrder, this.conn);
							DataTable dataTable3 = this.conn.GetDataTable("select * from HLShop_OrderItem where OrderFormNum='" + text + "'");
							if (dataTable3 != null && dataTable3.Rows.Count > 0)
							{
								for (int j = 0; j < dataTable3.Rows.Count; j++)
								{
									string s = dataTable3.Rows[j]["ProductID"].ToString();
									int num14 = int.Parse(s);
									int num15 = int.Parse(dataTable3.Rows[j]["Quantity"].ToString());
									decimal value3 = 0m;
									if (dataTable3.Rows[j]["Price"] != DBNull.Value)
									{
										value3 = dataTable3.Rows[j]["Price"].ToDecimal2();
									}
									string commandText5 = "select PUnit from HLShop_Product where ProductID=" + num14;
									string unit = "";
									object obj2 = this.conn.ExecuteTransactionScalar(commandText5);
									if (obj2 != null)
									{
										unit = obj2.ToString();
									}
									string text3 = "";
									int num16 = 0;
									string sql2 = "select Stocks,BidTimes from HLShop_Product where ProductID=" + num14;
									DataTable dataTable4 = this.conn.GetDataTable(sql2);
									if (dataTable4.Rows.Count > 0)
									{
										if (dataTable4.Columns.Contains("BidTimes"))
										{
											if (dataTable4.Rows[0]["BidTimes"] != DBNull.Value)
											{
												text3 = ",BidTimes=BidTimes-1";
											}
											else
											{
												text3 = ",BidTimes=0";
											}
										}
										if (dataTable4.Columns.Contains("Stocks"))
										{
											if (dataTable4.Rows[0]["Stocks"] != DBNull.Value)
											{
												num16 = Convert.ToInt32(dataTable4.Rows[0]["Stocks"].ToString());
											}
										}
									}
									if (num16 > 0)
									{
										string commandText6 = string.Concat(new object[]
										{
											"update HLShop_Product set BuyTimes=BuyTimes-1,Stocks=",
											num16 + num15,
											text3,
											" where ProductID=",
											num14
										});
										this.conn.ExecuteTransaction(commandText6);
									}
									if (num13 > 0)
									{
										HKB.Data.Model.StockItemOrder stockItemOrder = new HKB.Data.Model.StockItemOrder();
										stockItemOrder.InfoOrderID = new int?(num13);
										stockItemOrder.InfoNumber = infoNumber;
										stockItemOrder.ProductID = new int?(num14);
										stockItemOrder.StockCount = new int?(num15);
										stockItemOrder.Price = new decimal?(value3);
										stockItemOrder.Unit = unit;
										BLLInstance.BllStockItemOrder.AddInfoTransaction(stockItemOrder, this.conn);
									}
								}
							}
						}
					}
					catch
					{
						this.conn.Rollback();
						flag = false;
					}
					finally
					{
						this.conn.Commit();
						flag = true;
					}
				}
			}
			result = flag;
			return result;
		}
		private void GetPayInfoMoneyAndIDBySqlWhere(ref decimal orderShopPayMoney, ref decimal orderFeeMoney, ref int payinfoID, ref string paytime, string sqlpwhere)
		{
			string sql = "Select MoneyPay,PaymentID,MoneyFee,PayTime From HLShop_PayInfo " + sqlpwhere;
			DataTable dataTable = this.conn.GetDataTable(sql);
			if (dataTable.Rows.Count > 0)
			{
				DataRow dataRow = dataTable.Rows[0];
				if (dataTable.Columns.Contains("MoneyPay"))
				{
					if (dataRow["MoneyPay"] != DBNull.Value)
					{
						orderShopPayMoney = dataRow["MoneyPay"].ToDecimal2();
					}
				}
				if (dataTable.Columns.Contains("MoneyFee"))
				{
					if (dataRow["MoneyFee"] != DBNull.Value)
					{
						orderFeeMoney = dataRow["MoneyFee"].ToDecimal2();
					}
				}
				if (dataTable.Columns.Contains("PaymentID"))
				{
					if (dataRow["PaymentID"] != DBNull.Value)
					{
						payinfoID = dataRow["PaymentID"].ToInt32(new int[0]);
					}
				}
				if (dataTable.Columns.Contains("PayTime"))
				{
					if (dataRow["PayTime"] != DBNull.Value)
					{
						paytime = dataRow["PayTime"].ToString();
					}
				}
			}
		}
		private void GetUser_BalanceFreezeMoney(int UserID, ref decimal user_Balance, ref decimal user_FreezeMoney)
		{
			string sql = "Select Balance,FreezeMoney From [HL_User] Where UserID=" + UserID;
			DataTable dataTable = this.conn.GetDataTable(sql);
			if (dataTable.Rows.Count > 0)
			{
				DataRow dataRow = dataTable.Rows[0];
				if (dataRow["Balance"] != DBNull.Value)
				{
					user_Balance = dataRow["Balance"].ToDecimal2();
				}
				if (dataRow["FreezeMoney"] != DBNull.Value)
				{
					user_FreezeMoney = dataRow["FreezeMoney"].ToDecimal2();
				}
			}
		}
		private void ShopBankOrderPayWayAndPayTip(int SalerID, int UserID, ref decimal userpayfee, ref decimal salerpayfee, ref string paywayType)
		{
			paywayType = this.shopconfig["PayWay"].ToString();
			Shop_PayType shop_PayType = new Shop_PayType(this.conn);
			DataTable shousuPay = shop_PayType.GetShousuPay(UserID);
			DataTable shousuPay2 = shop_PayType.GetShousuPay(SalerID);
			if (shousuPay.Rows.Count > 0)
			{
				if (shousuPay.Rows[0]["paytip"] != DBNull.Value)
				{
					userpayfee = shousuPay.Rows[0]["paytip"].ToDecimal2();
				}
			}
			if (shousuPay2.Rows.Count > 0)
			{
				if (shousuPay2.Rows[0]["paytip"] != DBNull.Value)
				{
					salerpayfee = shousuPay2.Rows[0]["paytip"].ToDecimal2();
				}
			}
		}
		public bool CusReceive(int OrderFormID)
		{
			DataTable dataTable = this.conn.GetDataTable("Select DeliverStatus,OrderFormNum,SalerID,UserID,SelectedPayType,Deliver_TotalPrice,Invoice_TotalPrice,MoneyGoods,MoneyTotal From [HLShop_Order] Where OrderFormID=" + OrderFormID);
			bool result;
			if (dataTable.Rows.Count <= 0)
			{
				result = false;
			}
			else
			{
				DataTable dataTable2 = this.conn.GetDataTable("select * from HLShop_DeliverItem where OrderID=" + OrderFormID);
				if (dataTable2.Rows.Count <= 0)
				{
					result = false;
				}
				else
				{
					string text = dataTable.Rows[0]["OrderFormNum"].ToString();
					int num = Convert.ToInt32(dataTable.Rows[0]["SalerID"]);
					int num2 = Convert.ToInt32(dataTable.Rows[0]["UserID"]);
					int num3 = dataTable.Rows[0]["SelectedPayType"].ToInt32(new int[0]);
					decimal num4 = 0m;
					decimal deliver_TotalPrice = 0m;
					decimal invoice_TotalPrice = 0m;
					if (dataTable.Rows[0]["MoneyGoods"] != DBNull.Value)
					{
						num4 = dataTable.Rows[0]["MoneyGoods"].ToDecimal2();
					}
					if (dataTable.Rows[0]["Deliver_TotalPrice"] != DBNull.Value)
					{
						deliver_TotalPrice = dataTable.Rows[0]["Deliver_TotalPrice"].ToDecimal2();
					}
					if (dataTable.Rows[0]["Invoice_TotalPrice"] != DBNull.Value)
					{
						invoice_TotalPrice = dataTable.Rows[0]["Invoice_TotalPrice"].ToDecimal2();
					}
					decimal d = (decimal)this.conn.GetScalar("Select Balance From [HL_User] Where UserID=" + num, new IDbDataParameter[0]);
					IDbDataParameter dbDataParameter = this.conn.CreateParameter("@Remark", DbType.String, "卖出商品订单");
					string inputer = "";
					string commandText = "Select UserName From [HL_User] Where UserID=" + num;
					object scalar = this.conn.GetScalar(commandText, new IDbDataParameter[0]);
					if (scalar != null)
					{
						inputer = scalar.ToString();
					}
					int num5 = 2;
					int num6 = 2;
					decimal num7 = 0m;
					decimal d2 = 0m;
					int num8 = 0;
					string value = "";
					decimal num9 = 0m;
					decimal d3 = 0m;
					string text2 = "";
					if (num3 == 0)
					{
						string sqlpwhere = "Where eBankID='ShopBank' and Status='NotPaySaler' and OrderFormNum='" + text + "' ";
						this.GetPayInfoMoneyAndIDBySqlWhere(ref num7, ref d2, ref num8, ref value, sqlpwhere);
						this.ShopBankOrderPayWayAndPayTip(num, num2, ref num9, ref d3, ref text2);
					}
					this.conn.BeginTransaction();
					try
					{
						UserExpAction userExpAction = new UserExpAction(this.conn);
						if (num3 == 0)
						{
							this.conn.ExecuteTransaction("Update HLShop_Order Set DeliverStatus=2 Where OrderFormID=" + OrderFormID);
							this.conn.ExecuteTransaction("Update HLShop_DeliverItem Set Received=1 Where DeliverType=0 and OrderID=" + OrderFormID);
							if (num7 > 0m)
							{
								decimal num10 = d + num7;
								decimal num11 = num7 + d2;
								decimal num12 = 0m;
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Insert Into HL_AccountDetails(UserID,cMoney,cType,uBalance,CreateTime,Remark) values(",
									num,
									",",
									num7,
									",1,",
									num10,
									",getdate(),@Remark)"
								}), new IDbDataParameter[]
								{
									dbDataParameter
								});
								decimal num13 = 0m;
								if (text2.Equals("0"))
								{
									num12 = num10;
									if (num13 > 0m)
									{
									}
								}
								else
								{
									if (text2.Equals("1"))
									{
										num13 = (num7 * d3 / 100m).ToDecimal2();
										num12 = num10 - num13;
										if (num13 > 0m)
										{
											this.conn.ExecuteTransaction(string.Concat(new object[]
											{
												"INSERT INTO HLShop_Records (UserId,OrderFormNum,Monery) VALUES(",
												num,
												",'",
												text,
												"',",
												num13,
												")"
											}));
											this.accountDetials.AddAccountDetailsByTransaction(num, num13, num12, 0, "支付订单的手续费");
										}
									}
									else
									{
										if (text2.Equals("2"))
										{
											num13 = (num7 * d3 / 100m).ToDecimal2();
											num12 = num10 - num13;
											if (num13 > 0m)
											{
												this.conn.ExecuteTransaction(string.Concat(new object[]
												{
													"INSERT INTO HLShop_Records (UserId,OrderFormNum,Monery) VALUES(",
													num,
													",'",
													text,
													"',",
													num13,
													")"
												}));
												this.accountDetials.AddAccountDetailsByTransaction(num, num13, num12, 0, "支付订单的手续费");
											}
										}
									}
								}
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"update HL_User set FreezeMoney=FreezeMoney-",
									num11,
									" where UserID=",
									num2
								}));
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Update HL_User Set Balance=",
									num12,
									" Where UserID=",
									num
								}));
								this.conn.ExecuteTransaction("Update HLShop_PayInfo Set Status='pay'  where PaymentID=" + num8);
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Update [HLShop_Order] Set PayStatus=",
									num6,
									",Status=",
									num5,
									",MoneyReceipt=",
									num11,
									" Where OrderFormNum='",
									text,
									"'"
								}));
								int num14 = num4.ToInt32(new int[0]);
								if (num14 > 0)
								{
									userExpAction.AddUserExpTransaction(num2, (long)num14, 1, "购买商品获得。订单编号为" + text, "+");
								}
								DataTable dataTable3 = BLLInstance.BllStockInfoOrder.GetList("OrderID=" + OrderFormID).Tables[0];
								for (int i = 0; i < dataTable3.Rows.Count; i++)
								{
									int num15 = dataTable3.Rows[i]["InfoOrderID"].ToInt32(new int[0]);
									string str = dataTable3.Rows[i]["InfoNumber"].ToString();
									HKB.Data.Model.StockInfoOrder model = BLLInstance.BllStockInfoOrder.GetModel(num15);
									if (model != null)
									{
										model.InfoOrderID = num15;
										model.Fee = new decimal?(num13);
										if (!string.IsNullOrEmpty(value))
										{
											model.ReceiptDate = new DateTime?(Convert.ToDateTime(value));
										}
										model.ReceiptMoney = new decimal?(num7);
										model.AlreadyReceiptMoney = new decimal?(num7 - num13);
										BLLInstance.BllStockInfoOrder.UpdateTransaction(model, this.conn);
									}
									if (this.BllGroup.OwnerPowerFinancemanage(num))
									{
										if (num15 > 0)
										{
											string accountANumber = "JZPZ" + DateTime.Now.TimeString();
											HKB.Data.Model.AccountAoucher accountAoucher = new HKB.Data.Model.AccountAoucher();
											accountAoucher.StockOrderID = new int?(num15);
											accountAoucher.AccountANumber = accountANumber;
											accountAoucher.AccountACount = new int?(1);
											accountAoucher.AccountAExplain = "编号" + str + "的出库单记账凭证";
											accountAoucher.Inputer = inputer;
											accountAoucher.IsCaudit = false;
											accountAoucher.IsAccount = false;
											accountAoucher.IsCashier = false;
											accountAoucher.InputDate = new DateTime?(DateTime.Now);
											accountAoucher.OwnerID = num;
											object obj = BLLInstance.BllAccountAoucher.AddTransaction(accountAoucher, this.conn);
											int num16 = 0;
											if (obj != null)
											{
												num16 = Convert.ToInt32(obj);
											}
											if (num16 > 0)
											{
												BLLInstance.BllAccountAoucherItem.AccountAoucherItemAddBySellTransaction(num16, num7, num4, deliver_TotalPrice, invoice_TotalPrice, num13, this.conn);
											}
										}
									}
								}
							}
						}
						else
						{
							string text3 = "Where eBankID='ShopBank' and Status='NotPaySaler' and OrderFormNum='" + text + "'";
							string str2 = "Where eBankID<>'ShopBank' and Status='NotPaySaler' and OrderFormNum='" + text + "'";
							this.conn.ExecuteTransaction("Update HLShop_Order Set DeliverStatus=2,Status=2 Where OrderFormID=" + OrderFormID);
							this.conn.ExecuteTransaction("Update HLShop_DeliverItem Set Received=1 Where OrderID=" + OrderFormID);
							int num14 = num4.ToInt32(new int[0]);
							if (num14 > 0)
							{
								userExpAction.AddUserExpTransaction(num2, (long)num14, 1, "购买商品获得。订单编号为" + text, "+");
							}
							object obj2 = this.conn.ExecuteTransactionScalar("Select sum(MoneyTrue) From HLShop_PayInfo " + text3);
							decimal num17 = 0m;
							if (obj2 != DBNull.Value)
							{
								num17 = (decimal)obj2;
							}
							if (num17 > 0m)
							{
								string userBalanceKey = Text.GetUserBalanceKey(num, d + num17);
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Update HL_User Set Balance=",
									d + num17,
									",EncryptMoney='",
									userBalanceKey,
									"' Where UserID=",
									num
								}));
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Insert Into HL_AccountDetails(UserID,cMoney,cType,uBalance,CreateTime,Remark) values(",
									num,
									",",
									num17,
									",1,",
									d + num17,
									",getdate(),@Remark)"
								}), new IDbDataParameter[]
								{
									dbDataParameter
								});
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Update HL_AccountDetails Set cType=0 Where ID in(Select OrderFormNum From HLShop_PayInfo ",
									text3,
									") and UserID=",
									num2
								}));
								this.conn.ExecuteTransaction("Update HLShop_PayInfo Set Status='Pay' " + text3);
							}
							obj2 = this.conn.ExecuteTransactionScalar("Select sum(MoneyTrue) From HLShop_PayInfo " + str2);
							decimal num18 = 0m;
							if (obj2 != DBNull.Value)
							{
								num18 = (decimal)obj2;
							}
							if (num18 > 0m)
							{
								d = (decimal)this.conn.GetScalar("Select Balance From [HL_User] Where UserID=" + num, new IDbDataParameter[0]);
								string userBalanceKey = Text.GetUserBalanceKey(num, d + num18);
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Update HL_User Set Balance=",
									d + num18,
									",EncryptMoney='",
									userBalanceKey,
									"' Where UserID=",
									num
								}));
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Insert Into HL_AccountDetails(UserID,cMoney,cType,uBalance,CreateTime,Remark) values(",
									num,
									",",
									num18,
									",1,",
									d + num18,
									",getdate(),@Remark)"
								}), new IDbDataParameter[]
								{
									dbDataParameter
								});
								this.conn.ExecuteTransaction("Update HLShop_PayInfo Set Status='Pay' " + str2);
							}
						}
					}
					catch (Exception ex)
					{
						this.conn.Rollback();
						ex.WriteErrorLog(new string[0]);
						result = false;
						return result;
					}
					this.conn.Commit();
					result = true;
				}
			}
			return result;
		}
		public void PayOrderOnline(int UserID, string OrderFormNum, int OrderID, int PayTypeID, decimal Money, string Remark, string ProductPath, bool isOffline)
		{
			HttpContext.Current.Session["payFrom"] = this.payFrom;
			Shop_Order shop_Order = new Shop_Order(this.conn);
			DataTable orderByOrderID = shop_Order.GetOrderByOrderID(OrderID);
			DataRow dataRow = orderByOrderID.Rows[0];
			Shop_PayType shop_PayType = new Shop_PayType(this.conn);
			DataTable typeByID = shop_PayType.GetTypeByID(PayTypeID);
			DataRow dataRow2 = typeByID.Rows[0];
			string text = dataRow2["PayTypeFlag"].ToString();
			if (text.Length > 4)
			{
				text.Substring(0, 4);
			}
			text = (Text.CheckChineaseName(text) ? "" : text);
			string text2 = text + DateTime.Now.ToString("yyyyMMddhhmmss") + Text.MakePassword(2);
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@Remark", DbType.String, Remark);
			this.conn.ExecuteTransaction(string.Concat(new object[]
			{
				"Insert Into HLShop_PayInfo(PaymentNum,PayTypeID,OrderFormNum,eBankID,MoneyPay,MoneyTrue,PayTime,Status,SalerID,UserID,UserName,Remark) Values('",
				text2,
				"',",
				PayTypeID,
				",'",
				OrderFormNum,
				"','",
				dataRow2["OnlinePay"],
				"',",
				Money,
				",",
				Money,
				",'",
				DateTime.Now,
				"','NotPay',",
				Convert.ToInt32(dataRow["SalerID"]),
				",",
				UserID,
				",'",
				dataRow["BuyerName"],
				"',@Remark)"
			}), new IDbDataParameter[]
			{
				dbDataParameter
			});
			this.conn.CloseConn();
			if (isOffline)
			{
				typeByID.Dispose();
				orderByOrderID.Dispose();
				HttpContext.Current.Response.Redirect("~/Member/shop_PayMents.aspx", true);
			}
			else
			{
				string a = dataRow2["OnlinePay"].ToString();
				if (a == "AliPay")
				{
				}
				if (a == "TrafutonQ")
				{
					HttpContext.Current.Response.Redirect("~/PayReturn/TenpayApp/index.aspx?OrderFormNum=" + OrderFormNum, true);
					orderByOrderID.Dispose();
				}
				DataTable dataTable = this.conn.GetDataTable("Select OrderFormID,OrderFormNum,SalerID,Status,PayStatus,DeliverStatus From [HLShop_Order] Where OrderFormID=" + OrderID);
				DataRow dataRow3 = dataTable.Rows[0];
				int sellerID = Convert.ToInt32(dataRow3["SalerID"].ToString());
				if (dataTable.Rows.Count <= 0)
				{
					this.WriteErrMsg("", Language.Get("Common/NotData") + "没有订单信息！", "");
				}
				DataTable fromOnlinePaySeting_ByUserID = shop_PayType.GetFromOnlinePaySeting_ByUserID(sellerID);
				if (fromOnlinePaySeting_ByUserID.Rows.Count <= 0)
				{
					this.WriteErrMsg("", Language.Get("Common/NotData") + "没有相关卖家信息！", "");
				}
				DataRow dataRow4 = fromOnlinePaySeting_ByUserID.Rows[0];
				string value = dataRow4["MerID"].ToString().Trim();
				string value2 = dataRow4["MerKey"].ToString().Trim();
				string value3 = dataRow4["MerName"].ToString().Trim();
				string value4 = this.config["SiteUrl"] + "PayReturn/OrderPay/OrderPayReturn/return_url_OrderPay.aspx";
				string value5 = this.config["SiteUrl"] + "PayReturn/OrderPay/OrderPayReturn/notify_url_OrderPay.aspx";
				string value6 = "";
				string value7 = text2;
				string value8 = dataRow["ProductName"].ToString();
				string value9 = dataRow["ProductName"].ToString();
				string value10 = Money.ToString().Trim();
				string value11 = dataRow["Deliver_TotalPrice"].ToString();
				string value12 = "express";
				string value13 = dataRow["ContacterName"].ToString();
				string value14 = dataRow["Province"].ToString();
				string value15 = dataRow["City"].ToString();
				string value16 = dataRow["Address"].ToString();
				string value17 = dataRow["Mobile"].ToString();
				string value18 = dataRow["Phone"].ToString();
				string value19 = "directPay";
				string value20 = "ICBCBTB";
				string value21 = "";
				string value22 = "";
				string value23 = "";
				string value24 = "";
				string value25 = "";
				string value26 = "";
				SortedDictionary<string, string> sortedDictionary = new SortedDictionary<string, string>();
				sortedDictionary.Add("payment_type", "1");
				sortedDictionary.Add("show_url", value6);
				sortedDictionary.Add("out_trade_no", value7);
				sortedDictionary.Add("subject", value8);
				sortedDictionary.Add("body", value9);
				sortedDictionary.Add("total_fee", value10);
				sortedDictionary.Add("paymethod", value19);
				sortedDictionary.Add("defaultbank", value20);
				sortedDictionary.Add("anti_phishing_key", value21);
				sortedDictionary.Add("exter_invoke_ip", value22);
				sortedDictionary.Add("extra_common_param", value23);
				sortedDictionary.Add("buyer_email", value24);
				sortedDictionary.Add("royalty_type", value25);
				sortedDictionary.Add("royalty_parameters", value26);
				sortedDictionary.Add("partner", value);
				sortedDictionary.Add("key", value2);
				sortedDictionary.Add("seller_email", value3);
				sortedDictionary.Add("return_url", value4);
				sortedDictionary.Add("notify_url", value5);
				sortedDictionary.Add("post_fee", value11);
				sortedDictionary.Add("logistics_type", value12);
				sortedDictionary.Add("receiver_name", value13);
				sortedDictionary.Add("receiver_address_prov", value14);
				sortedDictionary.Add("receiver_address_city", value15);
				sortedDictionary.Add("receiver_address", value16);
				sortedDictionary.Add("receiver_mobile", value17);
				sortedDictionary.Add("receiver_phone", value18);
				Service service = new Service();
				string s = service.Create_direct_pay_by_user(sortedDictionary);
				HttpContext.Current.Response.Write(s);
			}
		}
		public void updateMoney(int userID)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@UserID", DbType.Int32, userID)
			};
			decimal num = (decimal)this.conn.GetScalar("select top(1) uBalance from [HL_AccountDetails] where [UserID]=@UserID order by ID desc", parameters);
			IDbDataParameter[] parameters2 = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@UserID", DbType.Int32, userID),
				this.conn.CreateParameter("@Balance", DbType.Decimal, num)
			};
			this.conn.Execute("update [HL_User] set [Balance]=@Balance where [UserID]=@UserID", parameters2);
		}
		public bool PayReturn(string PaymentNum, string action)
		{
			string text = action;
			bool result;
			if (text != null)
			{
				if (!(text == "Pay"))
				{
					if (!(text == "NotPaySaler"))
					{
						goto IL_38;
					}
					action = "NotPaySaler";
				}
				else
				{
					action = "Pay";
				}
				DataTable dataTable = this.conn.GetDataTable("Select * From [HLShop_PayInfo] Where PaymentNum='" + PaymentNum + "'");
				if (dataTable.Rows.Count <= 0)
				{
					result = false;
					return result;
				}
				string text2 = dataTable.Rows[0]["OrderFormNum"].ToString();
				decimal num = Convert.ToDecimal(dataTable.Rows[0]["MoneyTrue"]);
				if (action != "Pay")
				{
					num = 0m;
				}
				DataTable dataTable2 = this.conn.GetDataTable("Select Status,DeliverStatus,PayStatus From HLShop_Order Where OrderFormNum='" + text2 + "'");
				if (dataTable2.Rows.Count <= 0)
				{
					result = false;
					return result;
				}
				int num2 = Convert.ToInt32(dataTable2.Rows[0]["Status"]);
				int num3 = Convert.ToInt32(dataTable2.Rows[0]["DeliverStatus"]);
				int num4 = Convert.ToInt32(dataTable2.Rows[0]["PayStatus"]);
				num2 = 1;
				num4 = 1;
				this.conn.BeginTransaction();
				try
				{
					this.conn.ExecuteTransaction(string.Concat(new string[]
					{
						"Update HLShop_PayInfo Set Status='",
						action,
						"' Where OrderFormNum='",
						text2,
						"'"
					}));
					this.conn.ExecuteTransaction(string.Concat(new object[]
					{
						"Update HLShop_Order Set Status=",
						num2,
						", PayStatus=",
						num4,
						",MoneyReceipt=MoneyReceipt+",
						num,
						" Where OrderFormNum='",
						text2,
						"'"
					}));
				}
				catch
				{
					this.conn.Rollback();
					result = false;
					return result;
				}
				this.conn.Commit();
				result = true;
				return result;
			}
			IL_38:
			result = false;
			return result;
		}
		public bool JustPaysMoneyAndquantity(int ProductID, int Cycle, decimal EarnestRebate)
		{
			int num = 0;
			int num2 = 0;
			DataTable dataTable = this.conn.GetDataTable(string.Concat(new object[]
			{
				"select * from HLShop_Order as a,HLShop_OrderItem as b where a.MoneyReceipt>0 and a.OrderFormID=b.OrderFormID and a.Cycle=",
				Cycle,
				" and b.ProductID=",
				ProductID
			}));
			if (dataTable.Rows.Count > 0 && dataTable != null)
			{
				for (int i = 0; i < dataTable.Rows.Count; i++)
				{
					if (dataTable.Rows[i]["Remembereffect"] != null && dataTable.Rows[i]["Remembereffect"].ToString() != "")
					{
						num2 = int.Parse(dataTable.Rows[i]["Remembereffect"].ToString());
					}
					if (decimal.Parse(dataTable.Rows[i]["MoneyGoods"].ToString()) * EarnestRebate / 100m <= decimal.Parse(dataTable.Rows[i]["MoneyReceipt"].ToString()) && num2 == 1)
					{
						num++;
					}
				}
			}
			return num == dataTable.Rows.Count;
		}
		public void ProcessingTeamData(int UserID, int ProductID, int BuyLeavel, int TeamNum)
		{
			int num = 0;
			DataTable dataTable = this.conn.GetDataTable(string.Concat(new object[]
			{
				"select TeamUserNum",
				BuyLeavel,
				" as TeamBuys from HLUser_RecordTeam where ProductID=",
				ProductID,
				" and UserID=",
				UserID
			}));
			if (dataTable != null && dataTable.Rows.Count > 0)
			{
				num = int.Parse(dataTable.Rows[0]["TeamBuys"].ToString());
			}
			switch (TeamNum)
			{
			case 1:
				if (BuyLeavel == 1)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_TeamRecords set TeamNum1=TeamNum1+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Product set TeamCurrentNumber1=TeamCurrentNumber1+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLUser_RecordTeam set TeamUserNum1=0 where ProductID=",
						ProductID,
						" and UserID=",
						UserID
					}));
				}
				break;
			case 2:
				if (BuyLeavel == 1)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_TeamRecords set TeamNum1=TeamNum1+",
						num,
						", TeamNum2=TeamNum2+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Product set TeamCurrentNumber1=TeamCurrentNumber1+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLUser_RecordTeam set TeamUserNum1=0 where ProductID=",
						ProductID,
						" and UserID=",
						UserID
					}));
				}
				else
				{
					if (BuyLeavel == 2)
					{
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_TeamRecords set TeamNum2=TeamNum2+",
							num,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_Product set TeamCurrentNumber2=TeamCurrentNumber2+",
							num,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLUser_RecordTeam set TeamUserNum2=0 where ProductID=",
							ProductID,
							" and UserID=",
							UserID
						}));
					}
				}
				break;
			case 3:
				if (BuyLeavel == 1)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_TeamRecords set TeamNum1=TeamNum1+",
						num,
						",TeamNum2=TeamNum2+",
						num,
						", TeamNum3=TeamNum3+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Product set TeamCurrentNumber1=TeamCurrentNumber1+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLUser_RecordTeam set TeamUserNum1=0 where ProductID=",
						ProductID,
						" and UserID=",
						UserID
					}));
				}
				else
				{
					if (BuyLeavel == 2)
					{
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_TeamRecords set TeamNum2=TeamNum2+",
							num,
							", TeamNum3=TeamNum3+",
							num,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_Product set TeamCurrentNumber2=TeamCurrentNumber2+",
							num,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLUser_RecordTeam set TeamUserNum2=0 where ProductID=",
							ProductID,
							" and UserID=",
							UserID
						}));
					}
					else
					{
						if (BuyLeavel == 3)
						{
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_TeamRecords set TeamNum3=TeamNum3+",
								num,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_Product set TeamCurrentNumber3=TeamCurrentNumber3+",
								num,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLUser_RecordTeam set TeamUserNum3=0 where ProductID=",
								ProductID,
								" and UserID=",
								UserID
							}));
						}
					}
				}
				break;
			case 4:
				if (BuyLeavel == 1)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_TeamRecords set TeamNum1=TeamNum1+",
						num,
						",TeamNum2=TeamNum2+",
						num,
						",TeamNum3=TeamNum3+",
						num,
						" ,TeamNum4=TeamNum4+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Product set TeamCurrentNumber1=TeamCurrentNumber1+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLUser_RecordTeam set TeamUserNum1=0 where ProductID=",
						ProductID,
						" and UserID=",
						UserID
					}));
				}
				else
				{
					if (BuyLeavel == 2)
					{
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_TeamRecords set TeamNum2=TeamNum2+",
							num,
							",TeamNum3=TeamNum3+",
							num,
							", TeamNum4=TeamNum4+",
							num,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_Product set TeamCurrentNumber2=TeamCurrentNumber2+",
							num,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLUser_RecordTeam set TeamUserNum2=0 where ProductID=",
							ProductID,
							" and UserID=",
							UserID
						}));
					}
					else
					{
						if (BuyLeavel == 3)
						{
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_TeamRecords set TeamNum3=TeamNum3+",
								num,
								", TeamNum4=TeamNum4+",
								num,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_Product set TeamCurrentNumber3=TeamCurrentNumber3+",
								num,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLUser_RecordTeam set TeamUserNum3=0 where ProductID=",
								ProductID,
								" and UserID=",
								UserID
							}));
						}
						else
						{
							if (BuyLeavel == 4)
							{
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLShop_TeamRecords set TeamNum4=TeamNum4+",
									num,
									" where ProductID=",
									ProductID
								}));
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLShop_Product set TeamCurrentNumber4=TeamCurrentNumber4+",
									num,
									" where ProductID=",
									ProductID
								}));
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLUser_RecordTeam set TeamUserNum4=0 where ProductID=",
									ProductID,
									" and UserID=",
									UserID
								}));
							}
						}
					}
				}
				break;
			case 5:
				if (BuyLeavel == 1)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_TeamRecords set TeamNum1=TeamNum1+",
						num,
						",TeamNum2=TeamNum2+",
						num,
						",TeamNum3=TeamNum3+",
						num,
						",TeamNum4=TeamNum4+",
						num,
						", TeamNum5=TeamNum5+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Product set TeamCurrentNumber1=TeamCurrentNumber1+",
						num,
						" where ProductID=",
						ProductID
					}));
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLUser_RecordTeam set TeamUserNum1=0 where ProductID=",
						ProductID,
						" and UserID=",
						UserID
					}));
				}
				else
				{
					if (BuyLeavel == 2)
					{
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_TeamRecords set TeamNum2=TeamNum2+",
							num,
							",TeamNum3=TeamNum3+",
							num,
							",TeamNum4=TeamNum4+",
							num,
							", TeamNum5=TeamNum5+",
							num,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_Product set TeamCurrentNumber2=TeamCurrentNumber2+",
							num,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLUser_RecordTeam set TeamUserNum2=0 where ProductID=",
							ProductID,
							" and UserID=",
							UserID
						}));
					}
					else
					{
						if (BuyLeavel == 3)
						{
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_TeamRecords set TeamNum3=TeamNum3+",
								num,
								",TeamNum4=TeamNum4+",
								num,
								", TeamNum5=TeamNum5+",
								num,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_Product set TeamCurrentNumber3=TeamCurrentNumber3+",
								num,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLUser_RecordTeam set TeamUserNum3=0 where ProductID=",
								ProductID,
								" and UserID=",
								UserID
							}));
						}
						else
						{
							if (BuyLeavel == 4)
							{
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLShop_TeamRecords set TeamNum4=TeamNum4+",
									num,
									", TeamNum5=TeamNum5+",
									num,
									" where ProductID=",
									ProductID
								}));
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLShop_Product set TeamCurrentNumber4=TeamCurrentNumber4+",
									num,
									" where ProductID=",
									ProductID
								}));
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLUser_RecordTeam set TeamUserNum4=0 where ProductID=",
									ProductID,
									" and UserID=",
									UserID
								}));
							}
							else
							{
								if (BuyLeavel == 5)
								{
									this.conn.Execute(string.Concat(new object[]
									{
										"Update HLShop_TeamRecords set TeamNum5=TeamNum5+",
										num,
										" where ProductID=",
										ProductID
									}));
									this.conn.Execute(string.Concat(new object[]
									{
										"Update HLShop_Product set TeamCurrentNumber5=TeamCurrentNumber5+",
										num,
										" where ProductID=",
										ProductID
									}));
									this.conn.Execute(string.Concat(new object[]
									{
										"Update HLUser_RecordTeam set TeamUserNum5=0 where ProductID=",
										ProductID,
										" and UserID=",
										UserID
									}));
								}
							}
						}
					}
				}
				break;
			}
			Shop_Product shop_Product = new Shop_Product();
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			int num6 = 0;
			int num7 = 0;
			int num8 = 0;
			int num9 = 0;
			int num10 = 0;
			int num11 = 0;
			DataTable dataTable2 = this.conn.GetDataTable("select * from HLShop_TeamRecords where ProductID=" + ProductID);
			if (dataTable2 != null && dataTable2.Rows.Count > 0)
			{
				DataRow dataRow = dataTable2.Rows[0];
				num2 = int.Parse(dataRow["TeamNum1"].ToString());
				num3 = int.Parse(dataRow["TeamNum2"].ToString());
				num4 = int.Parse(dataRow["TeamNum3"].ToString());
				num5 = int.Parse(dataRow["TeamNum4"].ToString());
				num6 = int.Parse(dataRow["TeamNum5"].ToString());
			}
			dataTable2.Dispose();
			DataTable dataTable3 = this.conn.GetDataTable("select * from HLShop_Product where ProductID=" + ProductID);
			if (dataTable3 != null && dataTable3.Rows.Count > 0)
			{
				num7 = Convert.ToInt32(dataTable3.Rows[0]["TeamNumber1"]);
				num8 = Convert.ToInt32(dataTable3.Rows[0]["TeamNumber2"]);
				num9 = Convert.ToInt32(dataTable3.Rows[0]["TeamNumber3"]);
				num10 = Convert.ToInt32(dataTable3.Rows[0]["TeamNumber4"]);
				num11 = Convert.ToInt32(dataTable3.Rows[0]["TeamNumber5"]);
			}
			switch (TeamNum)
			{
			case 2:
				if (num2 >= num7 && num3 < num8)
				{
					bool flag = shop_Product.JustCycleSeparates(ProductID, 1);
				}
				break;
			case 3:
				if (num2 >= num7 && num3 < num8 && num4 < num9)
				{
					bool flag = shop_Product.JustCycleSeparates(ProductID, 1);
				}
				else
				{
					if (num3 >= num8 && num4 < num9)
					{
						bool flag = shop_Product.JustCycleSeparates(ProductID, 2);
					}
				}
				break;
			case 4:
				if (num2 >= num7 && num3 < num8 && num4 < num9 && num5 < num10)
				{
					bool flag = shop_Product.JustCycleSeparates(ProductID, 1);
				}
				else
				{
					if (num3 >= num8 && num4 < num9 && num5 < num10)
					{
						bool flag = shop_Product.JustCycleSeparates(ProductID, 2);
					}
					else
					{
						if (num4 >= num9 && num5 < num10)
						{
							bool flag = shop_Product.JustCycleSeparates(ProductID, 3);
						}
					}
				}
				break;
			case 5:
				if (num2 >= num7 && num3 < num8 && num4 < num9 && num5 < num10 && num6 < num11)
				{
					bool flag = shop_Product.JustCycleSeparates(ProductID, 1);
				}
				else
				{
					if (num3 >= num8 && num4 < num9 && num5 < num10 && num6 < num11)
					{
						bool flag = shop_Product.JustCycleSeparates(ProductID, 2);
					}
					else
					{
						if (num4 >= num9 && num5 < num10 && num6 < num11)
						{
							bool flag = shop_Product.JustCycleSeparates(ProductID, 3);
						}
						else
						{
							if (num5 >= num10 && num6 < num11)
							{
								bool flag = shop_Product.JustCycleSeparates(ProductID, 4);
							}
						}
					}
				}
				break;
			}
		}
		public void UpdataTeamRemembereffectOrder(int ProductID, int Cycle)
		{
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			int num6 = 0;
			int num7 = 0;
			int num8 = 0;
			int num9 = 0;
			int num10 = 0;
			int num11 = 0;
			DataTable dataTable = this.conn.GetDataTable("select * from HLShop_Product where ProductID=" + ProductID);
			if (dataTable != null && dataTable.Rows.Count > 0)
			{
				num = int.Parse(dataTable.Rows[0]["TeamNumber1"].ToString());
				num2 = int.Parse(dataTable.Rows[0]["TeamNumber2"].ToString());
				num3 = int.Parse(dataTable.Rows[0]["TeamNumber3"].ToString());
				num4 = int.Parse(dataTable.Rows[0]["TeamNumber4"].ToString());
				num5 = int.Parse(dataTable.Rows[0]["TeamNumber5"].ToString());
				num11 = int.Parse(dataTable.Rows[0]["TeamNum"].ToString());
			}
			dataTable.Dispose();
			DataTable dataTable2 = this.conn.GetDataTable("select * from HLShop_TeamRecords where ProductID=" + ProductID);
			if (dataTable2 != null && dataTable2.Rows.Count > 0)
			{
				num6 = int.Parse(dataTable2.Rows[0]["TeamNum1"].ToString());
				num7 = int.Parse(dataTable2.Rows[0]["TeamNum2"].ToString());
				num8 = int.Parse(dataTable2.Rows[0]["TeamNum3"].ToString());
				num9 = int.Parse(dataTable2.Rows[0]["TeamNum4"].ToString());
				num10 = int.Parse(dataTable2.Rows[0]["TeamNum5"].ToString());
			}
			dataTable2.Dispose();
			switch (num11)
			{
			case 1:
				if (num6 >= num)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Order set Remembereffect=1 where OrderFormID in(select OrderFormID from HLShop_OrderItem where MoneyReceipt>0 and ProductID=",
						ProductID,
						") and MoneyReceipt>0 and Cycle=",
						Cycle
					}));
				}
				break;
			case 2:
				if (num6 >= num || num7 >= num2)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Order set Remembereffect=1 where OrderFormID in(select OrderFormID from HLShop_OrderItem where MoneyReceipt>0 and ProductID=",
						ProductID,
						") and MoneyReceipt>0 and Cycle=",
						Cycle
					}));
				}
				break;
			case 3:
				if (num6 >= num || num7 >= num2 || num8 >= num3)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Order set Remembereffect=1 where OrderFormID in(select OrderFormID from HLShop_OrderItem where MoneyReceipt>0 and ProductID=",
						ProductID,
						") and MoneyReceipt>0 and Cycle=",
						Cycle
					}));
				}
				break;
			case 4:
				if (num6 >= num || num7 >= num2 || num8 >= num3 || num9 >= num4)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Order set Remembereffect=1 where OrderFormID in(select OrderFormID from HLShop_OrderItem where MoneyReceipt>0 and ProductID=",
						ProductID,
						") and MoneyReceipt>0 and Cycle=",
						Cycle
					}));
				}
				break;
			case 5:
				if (num6 >= num || num7 >= num2 || num8 >= num3 || num9 >= num4 || num10 >= num5)
				{
					this.conn.Execute(string.Concat(new object[]
					{
						"Update HLShop_Order set Remembereffect=1 where OrderFormID in(select OrderFormID from HLShop_OrderItem where MoneyReceipt>0 and ProductID=",
						ProductID,
						") and MoneyReceipt>0 and Cycle=",
						Cycle
					}));
				}
				break;
			}
		}
		public void ClearRecord(int ProductID, int Cycle)
		{
			Shop_Product shop_Product = new Shop_Product();
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			int num6 = 0;
			int num7 = 0;
			int num8 = 0;
			int num9 = 0;
			int num10 = 0;
			int num11 = 0;
			int num12 = 0;
			decimal currentPrice = 0m;
			decimal currentPrice2 = 0m;
			decimal currentPrice3 = 0m;
			decimal currentPrice4 = 0m;
			decimal currentPrice5 = 0m;
			DataTable dataTable = this.conn.GetDataTable("select * from HLShop_Product where ProductID=" + ProductID);
			if (dataTable != null && dataTable.Rows.Count > 0)
			{
				num2 = int.Parse(dataTable.Rows[0]["TeamNumber1"].ToString());
				num3 = int.Parse(dataTable.Rows[0]["TeamNumber2"].ToString());
				num4 = int.Parse(dataTable.Rows[0]["TeamNumber3"].ToString());
				num5 = int.Parse(dataTable.Rows[0]["TeamNumber4"].ToString());
				num6 = int.Parse(dataTable.Rows[0]["TeamNumber5"].ToString());
				num12 = int.Parse(dataTable.Rows[0]["TeamNum"].ToString());
				currentPrice = decimal.Parse(dataTable.Rows[0]["TeamPrice1"].ToString());
				currentPrice2 = decimal.Parse(dataTable.Rows[0]["TeamPrice2"].ToString());
				currentPrice3 = decimal.Parse(dataTable.Rows[0]["TeamPrice3"].ToString());
				currentPrice4 = decimal.Parse(dataTable.Rows[0]["TeamPrice4"].ToString());
				currentPrice5 = decimal.Parse(dataTable.Rows[0]["TeamPrice5"].ToString());
			}
			dataTable.Dispose();
			DataTable dataTable2 = this.conn.GetDataTable("select * from HLShop_TeamRecords where ProductID=" + ProductID);
			if (dataTable2 != null && dataTable2.Rows.Count > 0)
			{
				num7 = int.Parse(dataTable2.Rows[0]["TeamNum1"].ToString());
				num8 = int.Parse(dataTable2.Rows[0]["TeamNum2"].ToString());
				num9 = int.Parse(dataTable2.Rows[0]["TeamNum3"].ToString());
				num10 = int.Parse(dataTable2.Rows[0]["TeamNum4"].ToString());
				num11 = int.Parse(dataTable2.Rows[0]["TeamNum5"].ToString());
			}
			dataTable2.Dispose();
			DataTable dataTable3 = this.conn.GetDataTable(string.Concat(new object[]
			{
				"select Quantity from HLShop_Order as a, HLShop_OrderItem as b where a.OrderFormID=b.OrderFormID and a.Cycle=",
				Cycle,
				" and b.ProductID=",
				ProductID
			}));
			if (dataTable3 != null && dataTable3.Rows.Count > 0)
			{
				for (int i = 0; i < dataTable3.Rows.Count; i++)
				{
					num += int.Parse(dataTable3.Rows[i]["Quantity"].ToString());
				}
			}
			dataTable3.Dispose();
			switch (num12)
			{
			case 1:
				if (num7 >= num2)
				{
					shop_Product.AttimesUpdateTeamPrice(1, ProductID, Cycle, currentPrice);
					this.conn.Execute("Update HLShop_TeamRecords set TeamNum1=0 where ProductID=" + ProductID);
					this.conn.Execute("Update HLShop_Product set TeamCurrentNumber1=0 where ProductID=" + ProductID);
				}
				break;
			case 2:
				if (num8 >= num3)
				{
					shop_Product.AttimesUpdateTeamPrice(2, ProductID, Cycle, currentPrice2);
					this.conn.Execute("Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0 where ProductID=" + ProductID);
					this.conn.Execute("Update HLShop_Product set TeamCurrentNumber2=0 where ProductID=" + ProductID);
				}
				else
				{
					if (num7 >= num2)
					{
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=TeamNum2-",
							num7,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute("Update HLShop_Product set TeamCurrentNumber1=0 where ProductID=" + ProductID);
					}
				}
				break;
			case 3:
				if (num9 >= num4)
				{
					shop_Product.AttimesUpdateTeamPrice(3, ProductID, Cycle, currentPrice3);
					this.conn.Execute("Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=0 where ProductID=" + ProductID);
					this.conn.Execute("Update HLShop_Product set TeamCurrentNumber3=0 where ProductID=" + ProductID);
				}
				else
				{
					if (num8 >= num3)
					{
						shop_Product.AttimesUpdateTeamPrice(3, ProductID, Cycle, currentPrice2);
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=TeamNum3-",
							num8,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute("Update HLShop_Product set TeamCurrentNumber2=0 where ProductID=" + ProductID);
					}
					else
					{
						if (num7 >= num2)
						{
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=TeamNum2-",
								num7,
								",TeamNum3=TeamNum3-",
								num7,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute("Update HLShop_Product set TeamCurrentNumber1=0 where ProductID=" + ProductID);
						}
					}
				}
				break;
			case 4:
				if (num10 >= num5)
				{
					shop_Product.AttimesUpdateTeamPrice(4, ProductID, Cycle, currentPrice4);
					this.conn.Execute("Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=0,TeamNum4=0 where ProductID=" + ProductID);
					this.conn.Execute("Update HLShop_Product set TeamCurrentNumber4=0 where ProductID=" + ProductID);
				}
				else
				{
					if (num9 >= num4)
					{
						shop_Product.AttimesUpdateTeamPrice(4, ProductID, Cycle, currentPrice3);
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=0,TeamNum4=TeamNum4-",
							num9,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute("Update HLShop_Product set TeamCurrentNumber3=0 where ProductID=" + ProductID);
					}
					else
					{
						if (num8 >= num3)
						{
							shop_Product.AttimesUpdateTeamPrice(4, ProductID, Cycle, currentPrice2);
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=TeamNum3-",
								num8,
								",TeamNum4=TeamNum4-",
								num8,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute("Update HLShop_Product set TeamCurrentNumber2=0 where ProductID=" + ProductID);
						}
						else
						{
							if (num7 >= num2)
							{
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=TeamNum2-",
									num7,
									",TeamNum3=TeamNum3-",
									num7,
									",TeamNum4=TeamNum4-",
									num7,
									" where ProductID=",
									ProductID
								}));
								this.conn.Execute("Update HLShop_Product set TeamCurrentNumber1=0 where ProductID=" + ProductID);
							}
						}
					}
				}
				break;
			case 5:
				if (num11 >= num6)
				{
					shop_Product.AttimesUpdateTeamPrice(5, ProductID, Cycle, currentPrice5);
					this.conn.Execute("Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=0,TeamNum4=0,TeamNum5=0 where ProductID=" + ProductID);
					this.conn.Execute("Update HLShop_Product set TeamCurrentNumber5=0 where ProductID=" + ProductID);
				}
				else
				{
					if (num10 >= num5)
					{
						shop_Product.AttimesUpdateTeamPrice(5, ProductID, Cycle, currentPrice4);
						this.conn.Execute(string.Concat(new object[]
						{
							"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=0,TeamNum4=0,TeamNum5=TeamNum5-",
							num10,
							" where ProductID=",
							ProductID
						}));
						this.conn.Execute("Update HLShop_Product set TeamCurrentNumber4=0 where ProductID=" + ProductID);
					}
					else
					{
						if (num9 >= num4)
						{
							shop_Product.AttimesUpdateTeamPrice(5, ProductID, Cycle, currentPrice3);
							this.conn.Execute(string.Concat(new object[]
							{
								"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=0,TeamNum4=TeamNum4-",
								num9,
								",TeamNum5=TeamNum5-",
								num9,
								" where ProductID=",
								ProductID
							}));
							this.conn.Execute("Update HLShop_Product set TeamCurrentNumber3=0 where ProductID=" + ProductID);
						}
						else
						{
							if (num8 >= num3)
							{
								shop_Product.AttimesUpdateTeamPrice(5, ProductID, Cycle, currentPrice2);
								this.conn.Execute(string.Concat(new object[]
								{
									"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=0,TeamNum3=TeamNum3-",
									num8,
									",TeamNum4=TeamNum4-",
									num8,
									",TeamNum5=TeamNum5-",
									num8,
									" where ProductID=",
									ProductID
								}));
								this.conn.Execute("Update HLShop_Product set TeamCurrentNumber2=0 where ProductID=" + ProductID);
							}
							else
							{
								if (num7 >= num2)
								{
									this.conn.Execute(string.Concat(new object[]
									{
										"Update HLShop_TeamRecords set TeamNum1=0,TeamNum2=TeamNum2-",
										num7,
										",TeamNum3=TeamNum3-",
										num7,
										",TeamNum4=TeamNum4-",
										num7,
										",TeamNum5=TeamNum5-",
										num7,
										" where ProductID=",
										ProductID
									}));
									this.conn.Execute("Update HLShop_Product set TeamCurrentNumber1=0 where ProductID=" + ProductID);
								}
							}
						}
					}
				}
				break;
			}
		}
		public void insertHLAcount(decimal cmoney, int ctyp, decimal ublance, string remark, int userid)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@createtime", DbType.DateTime, DateTime.Now),
				this.conn.CreateParameter("@cmoney", DbType.Decimal, cmoney),
				this.conn.CreateParameter("@ctyp", DbType.Int32, ctyp),
				this.conn.CreateParameter("@ublance", DbType.Decimal, ublance),
				this.conn.CreateParameter("@remark", DbType.String, remark),
				this.conn.CreateParameter("@userid", DbType.Int32, userid)
			};
			this.conn.Execute("inser into HL_HL_AccountDetails (CreateTime, cMoney, cType, uBalance, Remark, UserID) values (@createtime,@cmoney,@ctyp,@ublance,@remark,@userid)", parameters);
		}
	}
}
